package com.linhai.scm.struts2;

import org.springframework.beans.factory.annotation.Autowired;

import com.linhai.scm.entity.base.User;
import com.linhai.scm.service.IUserService;
import com.linhai.scm.struts2.base.BaseAction;

//public class NewsAction extends ActionSupport {
public class UserAction extends BaseAction{
	
	private static final long serialVersionUID = 541123664076314734L;

	@Autowired
	private IUserService service;
	
	private User user;

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}
	
	public String execute() throws Exception{
		boolean isok=true;
		isok=service.auth(user);
		if(isok){
			return "success";
		}else{
			return "error";
		}
	}
	
	public String getTestJSON() throws Exception{
		response.setContentType("text/html;charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
		java.io.PrintWriter out=null;
		try {
			out = response.getWriter();
			out.write("JSON字符串");
		} catch (java.io.IOException e) {
			System.out.println("出错了！");
		}
		out.flush();
		out.close();
		return null;
    }
}
